/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef NAPI_X509_CERT_SELECTOR_H
#define NAPI_X509_CERT_SELECTOR_H

#include <string>

#include "napi/native_api.h"
#include "napi/native_common.h"
#include "x509_cert_selector.h"

namespace OHOS {
namespace CertFramework {



class NapiX509CertSelector {
public:
    explicit NapiX509CertSelector(HcfX509CertSelector *selector);
    ~NapiX509CertSelector();

    static void DefineX509CertSelectorJSClass(napi_env env, napi_value exports);
    static napi_value CreateX509CertSelector(napi_env env, napi_callback_info info);

    // napi_value GetUint8Array(napi_env env, napi_callback_info info, int32_t field);

    static HcfX509CertSelector* GetCertSelector(napi_env env, napi_callback_info info);
    static napi_value GetRhs(napi_env env, napi_callback_info info);

    static napi_value GetSubjectAlternativeNames(napi_env env, napi_callback_info info);
    static napi_value GetMatchAllSubjectAltNames(napi_env env, napi_callback_info info);
    static napi_value GetAuthorityKeyIdentifier(napi_env env, napi_callback_info info);
    static napi_value GetMinPathLenConstraint(napi_env env, napi_callback_info info);
    static napi_value GetX509Cert(napi_env env, napi_callback_info info);
    static napi_value GetValidDate(napi_env env, napi_callback_info info);
    static napi_value GetIssuer(napi_env env, napi_callback_info info);
    static napi_value GetExtendedKeyUsage(napi_env env, napi_callback_info info);
    static napi_value GetKeyUsage(napi_env env, napi_callback_info info);
    static napi_value GetNameConstraint(napi_env env, napi_callback_info info);
    static napi_value GetCertPolicy(napi_env env, napi_callback_info info);
    static napi_value GetPrivateKeyValid(napi_env env, napi_callback_info info);
    static napi_value GetSerialNumber(napi_env env, napi_callback_info info);
    static napi_value GetSubject(napi_env env, napi_callback_info info);
    static napi_value GetSubjectKeyIdentifier(napi_env env, napi_callback_info info);
    static napi_value GetPublicKey(napi_env env, napi_callback_info info);
    static napi_value GetPublicKeyAlgID(napi_env env, napi_callback_info info);

    static napi_value SetSubjectAlternativeNames(napi_env env, napi_callback_info info);
    static napi_value SetMatchAllSubjectAltNames(napi_env env, napi_callback_info info);
    static napi_value SetAuthorityKeyIdentifier(napi_env env, napi_callback_info info);
    static napi_value SetMinPathLenConstraint(napi_env env, napi_callback_info info);
    static napi_value SetX509Cert(napi_env env, napi_callback_info info);
    static napi_value SetValidDate(napi_env env, napi_callback_info info);
    static napi_value SetIssuer(napi_env env, napi_callback_info info);
    static napi_value SetExtendedKeyUsage(napi_env env, napi_callback_info info);
    static napi_value SetKeyUsage(napi_env env, napi_callback_info info);
    static napi_value SetNameConstraint(napi_env env, napi_callback_info info);
    static napi_value SetCertPolicy(napi_env env, napi_callback_info info);
    static napi_value SetPrivateKeyValid(napi_env env, napi_callback_info info);
    static napi_value SetSerialNumber(napi_env env, napi_callback_info info);
    static napi_value SetSubject(napi_env env, napi_callback_info info);
    static napi_value SetSubjectKeyIdentifier(napi_env env, napi_callback_info info);
    static napi_value SetPublicKey(napi_env env, napi_callback_info info);
    static napi_value SetPublicKeyAlgID(napi_env env, napi_callback_info info);

    static napi_value AddSubjectAlternativeNames(napi_env env, napi_callback_info info);
    static napi_value Match(napi_env env, napi_callback_info info);
    
    HcfX509CertSelector *GetX509CertSelector()
    {
        return x509CertSelector_;
    }

    static thread_local napi_ref classRef_;

private:
    HcfX509CertSelector *x509CertSelector_ = nullptr;
};
} // namespace CertFramework
} // namespace OHOS

#endif // NAPI_X509_CERT_SELECTOR_H